﻿
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>云瑞家庭农场</title>
    <link rel="shortcut icon" href="~/Content/assets/i/miemie_favicon.ico" />
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Content/layui/layui.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-3.3.1.js"></script>
    <script type="text/javascript">
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date1'
            });

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');

            $(document).ready(function () {
                var _token = cookie("token");
                $.ajax({
                    url: "/YunRuiFarmAPI/GetLoginMessageAPI", //请求的URL
                    cache: true, //不从缓存中取数据
                    data: {
                        "Token": _token,
                    }, //发送的参数
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                })
                    .done(function (result) {
                        if (result.IsSuccess)
                            $("#Name").html("<img src= \"/Content/image/小埋1.jpg\" class=\"layui-nav-img\"/>" + result.Message)
                        else {
                            $("#Name").html("<img src= \"/Content/image/小埋1.jpg\" class=\"layui-nav-img\"/>" + "请先登录")
                            $("#UsecCenter").html("<dd><a href=\"/YunRuiFarm/Login\">登录</a></dd>");
                            $("#Operation").html("");
                        }
                    });
                $.ajax({
                    url: "/YunRuiFarmAPI/AgriculturalGetMessageAPI", //获取页面上的农副产品信息
                    cache: true, //不从缓存中取数据
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                })
                    .done(function (result) {
                        var commodity = "";
                        var i = 0;//行
                        var k = 0;//商品
                        for (; i < Math.ceil(result.count / 4); i++) {
                            commodity = commodity + "<div class=\"layui-row\">";
                            for (var j = 0; j < 4 && k < result.count; j++) {
                                commodity = commodity + "<div class=\"layui-col-sm3\">";
                                commodity = commodity + "<div id=\"commodity\">";
                                commodity = commodity + "<div id=\"commodity-img\"><img src=\"" + result.data[k].Picture + "\"/></div>";
                                commodity = commodity + "<div id=\"commodity-name\">" + result.data[k].Kind+"</div>"
                                commodity = commodity + "<div id=\"commodity-message\">" + result.data[k].Brief + "</div>";
                                commodity = commodity + "<div id=\"commodity-price\">￥" + result.data[k].Price +"</div>";
                                commodity = commodity + "<div id=\"commodity-button\"><button class=\"layui-btn\" onclick=\"Detail(" + result.data[k].Id+")\">查看详情</button></div>";
                                commodity = commodity + "</div>";
                                commodity = commodity + "</div>";
                                k++;
                            }
                            commodity = commodity + "</div>";
                        }
                        $("#content-right-message").html(commodity);
                        $("#img1").html("<img src=\"" + result.carouselfigure[0].PicUrl + "\"/>")
                    });
                $("#Cancellation").click(function () {
                    layer.msg("清除token");
                    delcookie("token", "", { expires: -1 });
                    location.reload();
                });
                $("#power").click(function () {
                    $.ajax({
                        url: "/YunRuiFarmAPI/GetAdministratorsPower", //请求的URL
                        cache: true, //不从缓存中取数据
                        data: {
                            "Token": _token
                        }, //发送的参数
                        type: 'post', //请求类型
                        dataType: 'json', //返回类型是JSON
                        timeout: 20000, //超时
                        error: function (xhr, err) {

                        },
                        success: function (result) {
                            if (result.IsSuccess)
                                window.location.href = result.Message;

                        }
                    })
                });
            });
            
            function GetUrlPara() {
                var url = document.location.toString();
                var arrUrl = url.split("=");
                var para = arrUrl[1];
                return para;
            }
            function cookie(key, value, options) {
                if (typeof value === "undefined") {
                    var cookies = document.cookie.split("; ");
                    for (var i = 0, len = cookies.length; i < len; i++) {
                        var cookie = cookies[i].split("=");
                        if (decodeURIComponent(cookie[0]) === key) {
                            return decodeURIComponent(cookie[1]);
                        }
                    }
                    return null;
                }
            }
            function delcookie(key, value, options) {
                options = options || {};
                var cookie = encodeURIComponent(key) + "=" + value;
                if ((typeof options.expires) !== "undefined") {
                    if (typeof options.expires === "number") {
                        var days = options.expires,
                            t = options.expires = new Date();
                        t.setDate(t.getDate() + days);
                    }
                    cookie += ";expires=" + options.expires.toUTCString();
                }
                if (typeof options.path !== "undefined")
                    cookie += ";path=" + options.path;
                if (typeof options.domain !== "undefined")
                    cookie += ";domain=" + options.domain;
                if (options.secure)
                    cookie += ";secure";
                document.cookie = cookie;
            }
        });
        function Detail(value) {
            window.location.href = "/YunRuiFarm/AgriculturalDetail?Id=" + value;
        }
    </script>
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });
        var url = document.location.toString();
        var arrUrl = url.split("=");
        var para = arrUrl[1];


    </script>
    <style>
        body {
            font-size: 18px;
        }

        #divtitle {
            margin: 0 auto;
            margin-top: 0px;
            margin-bottom: 0px;
        }


        #content-right {
            width: 100%;
            height: 100%;
            float: right
        }

        #content-right-message {
            
            width: 100%;
            float: left;
        }
        #content-right-top {
            float: left;
            width: 98%;
            height:450px;
            margin-left:1%;
            margin-right:1%;
        }
        #commodity {
            float: left;
            width: 98%;
            height: 270px;
            margin-left: 1%;
            margin-right: 1%;
            margin-top: 1%;
            margin-bottom: 1%;
            background-color: rgba(255,255,255,0.5);
           
        }
        #commodity-img {
            float: left;
            width: 96%;
            height: 160px;
            margin-top:1%;
            margin-bottom: 1%;
            margin-left:2%;
            margin-right:2%;
        }
        #commodity-name {
            float: left;
            width: 96%;
            margin-left: 5%;
            font-family:"微软雅黑"
        }
        #commodity-message {
            float: left;
            width: 96%;
            margin-left: 5%;
            font-size: 14px;
            font-family: "微软雅黑"
        }
        #commodity-price {
            float: left;
            width: 30%;
            height: 30px;
            margin-left: 5%;
            margin-right: 1%;
            color:darkorange;
            font-size:25px;
        }
        #commodity-button {
            float: right;
            height: 30px;
            margin-top: 1%;
            margin-bottom: 10%;
            margin-right: 5%;
        }
        img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header" style="width:auto">
            <div class="layui-logo" style=" background-image: url('../../Content/image/logo.jpg');background-size:100% 100%;"></div>
            <!-- 头部区域（可配合layui已有的水平导航） -->
            <ul class="layui-nav layui-layout-left" style="font-size: 20px;">
                <li class="layui-nav-item"><a href="/YunRuiFarm/Index">首页</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Adopt">羊领养预约</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Agricultural">农副产品预约</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Restaurant">餐饮预约</a></li>
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;" id="Name">
                        <img src="/Content/image/小埋1.jpg" class="layui-nav-img" />请先登录
                    </a>
                    <dl class="layui-nav-child" id="UsecCenter">
                        <dd><a href="/YunRuiFarm/UserInfo">基本资料</a></dd>
                        <dd><a href="/YunRuiFarm/UserAgriculturalOrder">我的订单</a></dd>
                        <dd><a href="/YunRuiFarm/UserFeedback">反馈信息</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" id="Operation">
                    <a href="javascript:;">账户操作</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="power">切换到管理员</a></dd>
                        <dd><a href="javascript:;" id="Cancellation">注销</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed">
                        <a class="" href="javascript:;">农副产品</a>
                        <dl class="layui-nav-child">
                            <dd><a href="/YunRuiFarm/Agricultural">农副产品信息</a></dd>
                            <dd><a href="/YunRuiFarm/UserAgriculturalOrder">我的订单</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>
        <div class="layui-body" style="background-image: url('../../Content/image/grass.jpg');background-repeat:no-repeat; background-attachment: fixed;background-size:100%">
            <!-- 内容主体区域 -->
            <div id="content-right-top">
                <div class="layui-carousel" id="test1" lay-filter="test1" style="margin: 0 auto;margin: 0px auto; height: 300px; width: 100%;">
                    <div carousel-item="" class="img-box">
                        <div id="img1">
                            <img src="~/Content/image/伊利亚.jpg" />
                        </div>
                        <div id="img1">
                            <img src="~/Content/image/伊利亚.jpg" />
                        </div>
                    </div>
                </div>
            </div>
            <div id="content-right">
                <div id="content-right-message">
                    
                </div>
            </div>
        </div>


    </div>
    <script>
        layui.use(['carousel', 'form'], function () {
            var carousel = layui.carousel
                , form = layui.form;



            //图片轮播
            carousel.render({
                elem: '#test1'
                , width: '100%'
                , height: '100%'
            });
            //其它示例

        });
    </script>
</body>
</html>
